import { TERMINAL_TYPE } from '../common/enums'
import request from '../common/request'

export interface IFriend {
  headImage: string
  id: number
  nickName: string
  online: boolean
  onlineApp: boolean
  onlineTerminals: TERMINAL_TYPE[]
  onlineWeb: boolean
}

const getFriendList = () => {
  return request({
    url: '/friend/list',
    method: 'GET'
  })
}

const getFriend = (id: number) => {
  return request({
    url: `/friend/find/${id}`,
    method: 'GET'
  })
}

const addFriend = (id: number) => {
  return request({
    url: `/friend/add?friendId=${id}`,
    method: "POST",
  })
}

const updateFriend = (data: IFriend) => {
  return request({
    url: '/friend/update',
    method: 'PUT',
    data
  })
}

const deleteFriend = (id: number) => {
  return request({
    url: `/friend/delete/${id}`,
    method: 'delete'
  })
}

export const friendApi = {
  getFriendList,
  getFriend,
  addFriend,
  updateFriend,
  deleteFriend,
}